import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Params} from "@angular/router";

@Component({
  selector: 'app-product1',
  templateUrl: './product1.component.html',
  styleUrls: ['./product1.component.css']
})
export class Product1Component implements OnInit {

  private  productId: number;

  constructor(private routeInfo: ActivatedRoute) { }

  ngOnInit() {
    // 参数订阅相同链接不同参数会不保存以前的值，会刷新
    this.routeInfo.params.subscribe((params: Params) => this.productId = params["id"]);
    // 参数快照，相同链接不同参数会保存以前的值，不会刷新
    // this.productId = this.routeInfo.snapshot.params["id"];
  }

}
